package com.example.rabbitdemo.exchanger.direct;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExchangeMessageProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;
    
    public void sendOrderMessage(String message) {
        // 指定交换机名称和路由键
        rabbitTemplate.convertAndSend(
                "exchange.direct", "order", message);
    }
    
    public void sendPaymentMessage(String message) {
        rabbitTemplate.convertAndSend(
                "exchange.direct", "payment", message);
    }
}